`include "defines.svh"
`include "CP0Defines.svh"
module NPC (
    input logic [31:0]PREIF_PC,
    input logic [1:0] IsExceptionorEret,
    input logic [31:0] CP0EPC_out,
    input logic [31:0] InEretAddr,
    input PredictResult IF_PredictResult,
    input logic [31:0] EXE_Correction_Vector,
    input logic EXE_PF_FlushAll,
    input logic EXE_Prediction_Failed,

    output logic [31:0]PREIF_NPC
);
    always_comb begin
        if(IsExceptionorEret==`IsException)
            PREIF_NPC=InEretAddr;
        else if(IsExceptionorEret==`IsEret)
            PREIF_NPC=CP0EPC_out;
        else if(EXE_Prediction_Failed||EXE_PF_FlushAll)
            PREIF_NPC=EXE_Correction_Vector;
        else if(IF_PredictResult.Valid)
            PREIF_NPC=IF_PredictResult.Target;
        else
            PREIF_NPC=PREIF_PC+4;
    end
endmodule 